package com.netty.chapter07_messagepack;


import com.google.common.collect.Lists;
import org.msgpack.MessagePack;
import org.msgpack.template.Templates;

import java.io.IOException;
import java.util.List;


/**
 * Package Name:com.netty.chapter07_messagepack
 * Description: That's the purpose of the file
 * Date:2016/9/3 13:43
 * Copyright (c) 2016, zhongmu@suneee.com All Rights Reserved.
 */
public class Netty01_msg_pack_api {

    public static void doSomething() throws IOException {
        List<String> lists = Lists.newArrayList();
        lists.add("jack");
        lists.add("jones");
        lists.add("marry");

        MessagePack messagePack = new MessagePack();
        //序列化开始
        byte[] bytes = messagePack.write(lists);

        //反序列化,用messagePack包含的模板去反序列化
        List<String> read = messagePack.read(bytes, Templates.tList(Templates.TString));

        System.out.println("read:"+read.get(0));
        System.out.println("read:"+read.get(1));
        System.out.println("read:"+read.get(2));
    }

    public static void main(String[] args) throws IOException {
        Netty01_msg_pack_api.doSomething();
    }

}
